from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

path = Service(executable_path=r'C:\Users\Laptop\Desktop\thirty_one\chromedriver.exe')
driver = webdriver.Chrome(service=path)
driver.maximize_window()
driver.implicitly_wait(10)
driver.get('https://mail.163.com')

driver.find_element(By.PARTIAL_LINK_TEXT,'企业邮箱').click() # 点击企业邮箱
driver.get_screenshot_as_file('切换前的窗口.png')
handles = driver.window_handles # 获取当前浏览器打开的所有窗口句柄，它是一个列表，最近打开的在列表末尾
# print(driver.current_window_handle) # 查看当前所在的窗口（句柄）
driver.switch_to.window(handles[-1]) # 切换到最近打开的窗口
driver.get_screenshot_as_file('企业邮箱窗口.png')
driver.find_element(By.ID,'regName').send_keys('1233')
driver.get_screenshot_as_file('企业邮箱窗口输入内容截图.png')